package com.doctcloud.hisinfo.histable.domain.comm;

import com.baomidou.mybatisplus.annotation.TableName;
import com.doctcloud.common.core.annotation.Excel;
import com.doctcloud.common.core.annotation.TableDesc;
import com.doctcloud.common.core.utils.StringUtils;
import lombok.*;
import org.springframework.util.ObjectUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;

import static com.doctcloud.common.core.utils.NumberUtils.processNumber;
import static com.doctcloud.common.core.utils.StringUtils.trim;

/**
 * @ClassName 计价项目记录
 * @Author samula
 * @Descripe product by com.doctcloud
 * @Data 2025-09-23 3:05
 **/
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(of = {"itemClass", "itemCode", "itemSpec", "units","startDate"})
@ToString
@TableDesc("价表")
public class PriceListDo implements Serializable {
    private static final long serialVersionUID = 1L;
    /** 项目分类 */
    @Excel(name = "项目分类")
    @NotBlank(message = "项目分类不能为空")
    private String itemClass;
    /** 项目代码 */
    @Excel(name = "项目代码")
    @NotBlank(message = "项目代码不能为空")
    private String itemCode;
    /** 项目名称 */
    @Excel(name = "项目名称")
    @NotBlank(message = "项目名称不能为空")
    private String itemName;
    /** 项目规格 */
    @Excel(name = "项目规格")
    @NotBlank(message = "项目规格不能为空")
    private String itemSpec;
    /** 单位 */
    @Excel(name = "单位")
    @NotBlank(message = "单位不能为空")
    private String units;
    /** 单价 */
    @Excel(name = "单价")
    @NotNull(message = "单价不能为空")
    private Double price;
    /** 优惠价格 */
    @Excel(name = "优惠价格")
    @NotNull(message = "单价不能为空")
    private Double preferPrice;
    /** 外宾价格 */
    @Excel(name = "外宾价格")
    @NotNull(message = "单价不能为空")
    private Double foreignerPrice;
    /** 执行科室代码 */
    @Excel(name = "执行科室代码")
    private String performedBy;
    /** 费别屏蔽标志 */
    @Excel(name = "费别屏蔽标志", readConverterExp = "0=考虑费别,1=不考虑费别")
    private String feeTypeMask;
    @Excel(name = "住院收据费用分类")
    private String classOnInpRcpt;
    @Excel(name = "门诊收据费用分类")
    private String classOnOutpRcpt;
    @Excel(name = "核算项目分类")
    private String classOnReckoning;
    @Excel(name = "会计科目")
    private String subjCode;
    @Excel(name = "病案首页费用分类")
    private String classOnMr;
    @Excel(name = "起用日期时间")
    private Date startDate;
    @Excel(name = "停用日期时间")
    private Date stopDate;

    @Data
    public static class primaryKey {
        private final String itemClass;
        private final String itemCode;
        private final String itemSpec;
        private final String units;
        private Date startDate;
        public primaryKey(String itemClass,String itemCode,String itemSpec,String units,Date startDate) {
            this.itemClass = itemClass;
            this.itemCode = itemCode;
            this.itemSpec = itemSpec;
            this.units = units;
            this.startDate = startDate;
        }
    }

    public void setItemClass(String itemClass) {
        this.itemClass = trim(itemClass);
    }

    public void setItemName(String itemName) {
        this.itemName = trim(itemName);
    }

    public void setItemCode(String itemCode) {
        this.itemCode = trim(itemCode);
    }

    public void setItemSpec(String itemSpec) {
        this.itemSpec = trim(itemSpec);
    }

    public void setUnits(String units) {
        this.units = trim(units);
    }

    public void setPrice(Double price) {
        this.price = processNumber(price,0.0);
    }

    public void setPreferPrice(Double preferPrice) {
        this.preferPrice = processNumber(preferPrice,0.0);
    }

    public void setForeignerPrice(Double foreignerPrice) {
        this.foreignerPrice = processNumber(foreignerPrice,0.0);
    }
}
